<template>
    <div>
        <h1>添加班级类型</h1>
        <el-row>
            <el-col :offset="6" :span="10"><el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="班级类型" prop="typeName">
                    <el-input v-model="ruleForm.typeName"></el-input>
                </el-form-item>
                <el-form-item label="排序" prop="sort" placeholder="请输入排序">
                    <el-input v-model="ruleForm.sort"></el-input>
                </el-form-item>
                <el-form-item label="类型说明" prop="info" placeholder="请输入类型说明">
                    <el-input type="textarea" v-model="ruleForm.info"></el-input>
                </el-form-item>
<!--                <el-form-item label="录入人" prop="inputId">-->
<!--                    <el-select placeholder="请选择录入人">-->
<!--                        <el-option :label="teacher.name" :value="teacher.id" v-for="teacher in teachers"></el-option>-->
<!--                    </el-select>-->
<!--                </el-form-item>-->
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">立即提交</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
            </el-form></el-col>
        </el-row>
    </div>
</template>

<script>
    export default {
        name: "ManageAddClassesType",
        data() {
            return {
                ruleForm: {
                    typeName: '',
                    info: '',
                    inputId: '1',
                    sort: ''
                },
                rules: {
                    typeName: [
                        { required: true, message: '请输入班级类型', trigger: 'blur' },
                        { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' }
                    ],
                    // inputId: [
                    //     { required: true, message: '请选择录入人', trigger: 'change' }
                    // ],
                },
                // teachers:[]
            };
        },
        created() {
            // this.getTeachers();
        },
        methods: {
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },
            // 获取教师列表
            // getTeachers(){
            //     this.$axios.get("manage/teacher/list").then(response=>{
            //         this.teachers = response.data.data;
            //         this.ruleForm.teacherId = this.teachers[0].id;
            //     });
            // },
            //提交
            onSubmit() {
                //调用表单验证，验证都通过valid为true，有一个不通过就为false
                this.$refs["ruleForm"].validate(valid=>{
                    if(valid){
                        this.$axios.post("manage/classesType/save",this.ruleForm).then(response=>{
                            //添加成功转到列表页面
                            this.$router.push("/manage/typeList");
                        });
                    }
                });
            },
        }
    }
</script>

<style scoped>

</style>